package shared;

import java.util.ArrayList;
import java.util.LinkedList;

import processing.core.PApplet;
import processing.core.PShape;

import birdsVSZombiesClient.gameGraphic.BVZGameShapeBoundaries;
import birdsVSZombiesClient.gameGraphic.BVZGameShapeBoxes;
import birdsVSZombiesClient.gameGraphic.BVZGameShapeCircles;

import jbox2dprocessing.compontent.AbstractBox2DShape;
import jbox2dprocessing.compontent.BaseBox;
import jbox2dprocessing.compontent.BaseCircle;
import jbox2dprocessing.compontent.BoundaryBox;

/**
 * The data sent from the Server to Clients.
 * <p>Use LinkedList to describe the physical items in the scene.<br/>
 * The message will be serialized into Json in the server and then send to the clients.<br/>
 * In clients the message will be deserialized back to message object by Gson.
 * @author yangliu
 * @version Version 0.0.4
 */
public class BVZServerToClientsMessages {
	
	public static PApplet parent;
	
	//	Server state
	public int ss;
	
	public int tt;
	
//	public PShape birdtexture;
	
	public LinkedList<BVZGameShapeBoxes> mb = new LinkedList<BVZGameShapeBoxes>();
	public LinkedList<BVZGameShapeCircles> mc = new LinkedList<BVZGameShapeCircles>();
	public LinkedList<BVZGameShapeBoundaries> mby = new LinkedList<BVZGameShapeBoundaries>();
	
	/**
	 * Pull the information from the Physical items and put them into the messages.
	 * @param ss 			The ServerStat.
	 * @param boundaries	The boundaries boxes in the scene.
	 * @param circles		The circles in the scene.
	 */
	public BVZServerToClientsMessages(int tt, int ss, LinkedList<BoundaryBox> boundaries, LinkedList<BaseCircle> circles, LinkedList<BaseBox> boxes) {
		this.ss = ss;
		
		if(boundaries != null && circles != null){
//			for(int i=0; i<boundaries.size(); i++){
//				BoundaryBox b = boundaries.get(i);
//				
//				BVZGameShapeBoundaries sb = new BVZGameShapeBoundaries(b.getPos().x, b.getPos().y, b.baseWidth, 
//						b.baseHeight, b.getAngle(), b.baseColor, b.baseStrokeColor, b.baseStrokeWeight);
//				this.mby.add(sb);
//			}
			
			for(int i=0; i<circles.size(); i++){
				BaseCircle c = circles.get(i);
				
				BVZGameShapeCircles sc = new BVZGameShapeCircles(c.baseType, c.getPos().x, c.getPos().y, c.baseRadius, 
						c.baseRadius, c.getAngle(), c.baseColor, c.baseStrokeColor, c.baseStrokeWeight);
				this.mc.add(sc);
			}
			
			for(int i=0; i<boxes.size(); i++){
				BaseBox b = boxes.get(i);
				
				BVZGameShapeBoxes sb = new BVZGameShapeBoxes(b.baseType, b.getPos().x, b.getPos().y, b.baseWidth,
						b.baseHeight, b.getAngle(), b.baseColor, b.baseStrokeColor, b.baseStrokeWeight);
				this.mb.add(sb);
			}

		}
	}
	
	public BVZServerToClientsMessages(int ss) {
		this(0,ss,null,null,null);
	}
	
	public BVZServerToClientsMessages() {
		this(0,1,null,null,null);
	}
}
